package com.slibra.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.slibra.business.domain.TXinyiDaily;
import com.slibra.business.service.ITXinyiDailyService;
import com.slibra.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.slibra.common.annotation.Log;
import com.slibra.common.core.controller.BaseController;
import com.slibra.common.core.domain.AjaxResult;
import com.slibra.common.enums.BusinessType;
import com.slibra.common.core.page.TableDataInfo;

/**
 * 信义日报数据Controller
 * 
 * @author slibra
 * @date 2024-04-13
 */
@RestController
@RequestMapping("/system/daily")
public class TXinyiDailyController extends BaseController
{
    @Autowired
    private ITXinyiDailyService tXinyiDailyService;

    /**
     * 查询信义日报数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:daily:list')")
    @GetMapping("/list")
    public TableDataInfo list(TXinyiDaily tXinyiDaily)
    {
        startPage();
        List<TXinyiDaily> list = tXinyiDailyService.selectTXinyiDailyList(tXinyiDaily);
        return getDataTable(list);
    }

    /**
     * 导出信义日报数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:daily:export')")
    @Log(title = "信义日报数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TXinyiDaily tXinyiDaily)
    {
        List<TXinyiDaily> list = tXinyiDailyService.selectTXinyiDailyList(tXinyiDaily);
        ExcelUtil<TXinyiDaily> util = new ExcelUtil<TXinyiDaily>(TXinyiDaily.class);
        util.exportExcel(response, list, "信义日报数据数据");
    }

    /**
     * 获取信义日报数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:daily:query')")
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") Long ID)
    {
        return success(tXinyiDailyService.selectTXinyiDailyByID(ID));
    }

    /**
     * 新增信义日报数据
     */
    @PreAuthorize("@ss.hasPermi('system:daily:add')")
    @Log(title = "信义日报数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TXinyiDaily tXinyiDaily)
    {
        return toAjax(tXinyiDailyService.insertTXinyiDaily(tXinyiDaily));
    }

    /**
     * 修改信义日报数据
     */
    @PreAuthorize("@ss.hasPermi('system:daily:edit')")
    @Log(title = "信义日报数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TXinyiDaily tXinyiDaily)
    {
        return toAjax(tXinyiDailyService.updateTXinyiDaily(tXinyiDaily));
    }

    /**
     * 删除信义日报数据
     */
    @PreAuthorize("@ss.hasPermi('system:daily:remove')")
    @Log(title = "信义日报数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable Long[] IDs)
    {
        return toAjax(tXinyiDailyService.deleteTXinyiDailyByIDs(IDs));
    }
}
